package com.htfyun.ft.fragment.engineer;

import android.os.Bundle;
import android.view.View;
import android.widget.CompoundButton;
import android.widget.Switch;

import com.htfyun.ft.R;
import com.htfyun.ft.fragment.BaseFragment;
import com.htfyun.ft.fragment.factory.FactoryTestItemsEnum;
import com.htfyun.ft.fragment.factory.ResultAttr;
import com.htfyun.hardware.AssistUtils;

import androidx.annotation.Nullable;

/**
 * Created by sst on 2018/7/11.
 */

public class FragmentAssistSettings extends BaseFragment {

    private final static String TAG = FragmentAssistSettings.class.getSimpleName();

    private Switch switchAdbEnabled;
    private Switch switchModifyTimeEnabled;
    private Switch switchHDScanEnabled;

    @Override
    protected int getLayoutRes() {
        return R.layout.fragment_engineer_assist_settings;
    }

    @Override
    protected void onInitView(@Nullable Bundle savedInstanceState) {

        switchAdbEnabled = findViewById(R.id.switchAdbEnabled);
        switchAdbEnabled.setChecked(AssistUtils.isADBEnabled(getContext()));
        switchAdbEnabled.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                AssistUtils.setADBEnabled(getContext(), isChecked);
            }
        });

        switchModifyTimeEnabled = findViewById(R.id.switchModifyTimeEnabled);
        switchModifyTimeEnabled.setChecked(AssistUtils.isModifyTimeEnabled());
        switchModifyTimeEnabled.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                AssistUtils.setModifyTimeEnabled(isChecked);
            }
        });

        switchHDScanEnabled = findViewById(R.id.switchHDScanEnabled);
        switchHDScanEnabled.setChecked(AssistUtils.isHardDiskScanEnabled());
        switchHDScanEnabled.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                AssistUtils.setHardDiskScanEnabled(isChecked);
            }
        });

    }

}
